<%@ Language = VBScript %>
<%  Option Explicit %>
<!--#include file="adovbs.inc"-->

<%
	    Dim objConn, objRSAlbums, objRSPhotos
    	Dim strSQL, strResults, strUserName
	    Dim iAlbumID
	    strResults = ""
	    iAlbumID = Request.QueryString("cat1")
	    strUserName = Request.QueryString("cat2")
	    Set objConn = Server.CreateObject("ADODB.Connection")	    
	    objConn.ConnectionString = "dsn=Developer;uid=JohnNgo;pwd=jo2.0G$!;"
	    objConn.Open
       
    	strSQL = "SELECT * FROM photos WHERE albumID = " & iAlbumID & " AND username = '" & strUserName & "' ORDER BY Priority ASC"
	    Set objRSPhotos = Server.CreateObject("ADODB.Recordset")
	    objRSPhotos.Open strSQL, objConn
	    If Not objRSPhotos.EOF then
		    strResults = "{""Results"": {""records"": ["
    	    Do While Not objRSPhotos.EOF
        	    strResults = strResults & "{""photoID"":"""	    
		        strResults = strResults & objRSPhotos("photoID") & ""","
    	        strResults = strResults & """username"":"""
    		    strResults = strResults & objRSPhotos("username") & ""","
	            strResults = strResults & """fileName"":"""
    		    strResults = strResults & objRSPhotos("fileName") & """," 
        	    strResults = strResults & """title"":"""
	    	    strResults = strResults & objRSPhotos("title") & """," 
    	        strResults = strResults & """description"":"""
    		    strResults = strResults & objRSPhotos("description") & ""","          
	            strResults = strResults & """dateTaken"":"""
    		    strResults = strResults & objRSPhotos("dateTaken") & ""","
        	    strResults = strResults & """albumID"":"""
		        strResults = strResults & objRSPhotos("albumID")
		        strResults = strResults & """}"
        	    strResults = strResults & ","
	        	objRSPhotos.MoveNext
	    	Loop	
    		strResults = Left(strResults, Len(strResults)-1)
    		strResults = strResults & "]}}@"
	    Else
    	    strResults = "not found@"
	    End If
    	objRSPhotos.Close
	    set objRSPhotos = Nothing
        
    	objConn.Close
	    set objConn = Nothing
    
		Response.Write(strResults)
%>